//
//  HotViewcontroller.m
//  YSBEmployer
//
//  Created by developer on 2021/12/05.
//  Copyright © 2021 ysb. All rights reserved.
//

#import "YSBChoiceTimeTypeView.h"
#import "YSBQuickReleaseOrderViewController.h"

#import "YSBOfflineReleaseViewController.h"

#import "YSBOfflineReleaseProfessionalWorkCell.h"


@implementation YSBOfflineReleaseViewController

- (void)clickProfessionalBtnClickAction {
    YSBChooseCareerViewController *vc = [[YSBChooseCareerViewController alloc] init];
    vc.myChooseCareer = self.skill_text;
    vc.cid = [NSString stringWithFormat:@"%ld",self.skill_id];
    vc.myClickBlock = ^(NSString *career,NSString *cid) {//选择后的回调
        self.skill_text = career;
        self.skill_id = cid.integerValue;

        NSIndexPath *indexPath = [NSIndexPath indexPathForRow:1 inSection:2];
        YSBOfflineReleaseProfessionalWorkCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
        [cell resetProfessionalWorkName:self.skill_text];
    };
    [self.navigationController pushViewController:vc animated:YES];
    
}

- (BOOL)verifyPositonParam {
    
    if (self.address_id == 0) {
        [SVProgressHUD showInfoWithStatus:@"请选择用工地点"];
        return NO;
    }
    
    if ([YSBCommonTool isBlankString:self.titleStr]) {
        [SVProgressHUD showInfoWithStatus:@"请输入招聘标题"];
        return NO;
    }
    
    if ([YSBCommonTool isBlankString:self.contents]) {
        [SVProgressHUD showInfoWithStatus:@"请输入岗位描述"];
        return NO;
    }
    
    if ([YSBCommonTool isBlankString:self.industry_name]) {
        [SVProgressHUD showInfoWithStatus:@"请输入所在行业"];
        return NO;
    }
    
    if ([YSBCommonTool isBlankString:self.skill_text]) {
        [SVProgressHUD showInfoWithStatus:@"请选择职业工种"];
        return NO;
    }
    if (self.skill_id == 0) {
        [SVProgressHUD showInfoWithStatus:@"职业工种不能设置为不限"];
        return NO;
    }
        
    if (self.gender <= -1) {
        [SVProgressHUD showInfoWithStatus:@"请选择性别"];
        return NO;
    }
    
    if (self.age_s <= -1 || self.age_e <= -1) {
        [SVProgressHUD showInfoWithStatus:@"请选择年龄"];
        return NO;
    }
    if (self.age_s < 16) {
        [SVProgressHUD showInfoWithStatus:@"最小年龄不能低于16岁"];
        return NO;
    }
    if (self.age_s > self.age_e) {
        [SVProgressHUD showInfoWithStatus:@"最小年龄不能高于最大年龄"];
        return NO;
    }
    
    
    if ([YSBCommonTool isBlankString:self.work_date]) {
        [SVProgressHUD showInfoWithStatus:@"请选择上班日期"];
        return NO;
    }
    
    if ([YSBCommonTool isBlankString:self.work_time]) {
        [SVProgressHUD showInfoWithStatus:@"请选择上班时间段"];
        return NO;
    }
    
    
    if (self.number == 0) {
        [SVProgressHUD showInfoWithStatus:@"请输入要招的人数"];
        return NO;
    }
    
    if ([YSBCommonTool isBlankString:self.price]) {
        [SVProgressHUD showInfoWithStatus:@"请输入工价"];
        return NO;
    }
    
    if ([YSBCommonTool isBlankString:self.salary_other_demand]) {
        [SVProgressHUD showInfoWithStatus:@"请详细描述您的结算周期"];
        return NO;
    }
    
    return YES;
}


@end


@interface YSBOfflineReleaseProfessionalWorkCell ()

- (void)resetProfessionalWorkName:(NSString *)professionalWorkName;


@end

@implementation YSBOfflineReleaseProfessionalWorkCell

- (void)resetProfessionalWorkName:(NSString *)professionalWorkName {
    _professionalWorkName = professionalWorkName;
    
    if (_professionalWorkName.length > 0) {
        _textField.text = _professionalWorkName;
        _textField.textColor = UIColor.ysb_3_Color;
    }else{
        _textField.text = @"请选择";
        _textField.textColor = UIColor.ysb_C_Color;
    }
}

@end





@implementation YSBQuickReleaseOrderViewController

- (void)configurationUI {
    
    [self setupSubViews];
    [self prepareSubViews];
    

    [self.timeTypeView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(self.view);
        make.height.mas_greaterThanOrEqualTo(@(110));
        make.top.mas_equalTo(self.addressView.mas_bottom);
    }];
    
    [self.requireInputView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(self.view);
        make.height.mas_equalTo(@(100));
        make.top.mas_equalTo(self.jobInputView.mas_bottom);
    }];
}


@end


@implementation YSBChoiceTimeTypeView

// 设置时间工作制
- (void)resetTimeType:(ChoiceTimeType)timeType {
    
    NSString *info = @"";
    
    UIColor *selectedBgColor = [UIColor colorWithHex:0xE8F1FF alpha:1];
    UIColor *selectedBgBorderColor = [UIColor colorWithHex:0x0069FF alpha:1];

    UIColor *noSelectedBgColor = [UIColor colorWithHex:0xF4F5F7 alpha:1];
    UIColor *noSelectedBgBorderColor = [UIColor colorWithHex:0xF4F5F7 alpha:1];
    
    self.timeType = timeType;
    if (self.timeType == 1) { //选择固定时间
        self.fixationBtn.selected = 1;
        self.fixationBtn.backgroundColor = selectedBgColor;
        self.fixationBtn.layer.borderColor = selectedBgBorderColor.CGColor;
        self.fixationBtn.layer.borderWidth = 0.5f;
        self.fixationBtn.titleLabel.font = [UIFont boldSystemFontOfSize:14];
        
        self.noFixationBtn.selected = 0;
        self.noFixationBtn.backgroundColor = noSelectedBgColor;
        self.noFixationBtn.layer.borderColor = noSelectedBgBorderColor.CGColor;
        self.noFixationBtn.layer.borderWidth = 0.5f;
        self.noFixationBtn.titleLabel.font = [UIFont boldSystemFontOfSize:14];
        
        info = @"固定时间:必须按照设置的时间段上下班打卡，此方式您将为雇员购买保险，建议您勾选此项";
    }
    else{ //选择非固定时间
        self.noFixationBtn.selected = 1;
        self.noFixationBtn.backgroundColor = selectedBgColor;
        self.noFixationBtn.layer.borderColor = selectedBgBorderColor.CGColor;
        self.noFixationBtn.layer.borderWidth = 0.5f;
        self.noFixationBtn.titleLabel.font = [UIFont boldSystemFontOfSize:14];
        
        self.fixationBtn.selected = 0;
        self.fixationBtn.backgroundColor = noSelectedBgColor;
        self.fixationBtn.layer.borderColor = noSelectedBgBorderColor.CGColor;
        self.fixationBtn.layer.borderWidth = 0.5f;
        self.fixationBtn.titleLabel.font = [UIFont boldSystemFontOfSize:14];
        
        info = @"不固定时间:在设置的时间段内可随时打上下班卡，工资按半小时计算，此方式您将无需为雇员购买保险，建议您勾选“固定时间”";
    }
    
    self.infoLabel.text = info;

}




@end
